
package rendi456.swing.console;

import java.awt.Color;
import java.awt.Component;
import java.awt.Font;

import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.ScrollPaneConstants;

import rendi456.swing.PaneManager;

public class ConsoleManager implements PaneManager
{
	public static final Color DEF_BACKGROUND = Color.BLACK;
	public static final Color DEF_FOREGROUND = Color.GREEN;
	public static final String DEF_FONT_TYPE = "Courier new";
	public static final int DEF_FONT_STYLE = 0;
	public static final int DEF_FONT_SIZE = 12;

	private JTextArea textArea = null;

	private String fontType = null;
	private int fontSize = 0;
	private int fontStyle = 0;

	public final OutputStream out;
	public final InputStream in;

	public ConsoleManager()
	{
		this.out = new OutputStream();
		this.in = new InputStream();
		this.textArea = new JTextArea();

		this.setFontType(ConsoleManager.DEF_FONT_TYPE);
		this.setFontStyle(ConsoleManager.DEF_FONT_STYLE);
		this.setFontSize(ConsoleManager.DEF_FONT_SIZE);
		this.updateFont();

		this.textArea.setBackground(ConsoleManager.DEF_BACKGROUND);
		this.textArea.setForeground(ConsoleManager.DEF_FOREGROUND);
		this.textArea.setLineWrap(true);
	}

	public void setEditable(boolean editable)
	{
		this.textArea.setEditable(editable);
	}

	public void setEnabled(boolean enabled)
	{
		this.textArea.setEnabled(enabled);
	}

	public void setFontType(String fontType)
	{
		this.fontType = fontType;
	}

	public void setFontSize(int fontSize)
	{
		this.fontSize = fontSize;
	}

	public void setFontStyle(int fontStyle)
	{
		this.fontStyle = fontStyle;
	}

	public void updateFont()
	{
		Font font = new Font(this.fontType, this.fontStyle, this.fontSize);
		this.textArea.setFont(font);
	}

	@Override
	public Component getPane()
	{
		return this.textArea;
	}

	public void setText(String text)
	{
		this.textArea.setText(text);
	}

	@Override
	public void refresh()
	{
		// TODO Auto-generated method stub

	}
}
